<?php $form = $this->beginWidget('CActiveForm', array(
    'id' => 'deal-form',
    'enableAjaxValidation' => false,
    'htmlOptions' => array(
        'role' => 'form',
        'class' => 'form-horizontal',
        'enctype' => 'multipart/form-data'
    )
)); ?>

<p class="note">Fields with <span class="required">*</span> are required.</p>

<?php if ($model->getErrors()) {
    ?>
    <div class="alert alert-error">
        <button class="close" data-dismiss="alert" type="button"> ×</button>
        <?php echo $form->errorSummary($model); ?>
    </div>
<?php } ?>
<div class="form admin-main-wrapper">
    <div class="block block-themed block-last">
        <div class="block-title">
            <h4></h4>
        </div>
        <div class="block-content">
            <div class="row control-group">
                <?php echo $form->labelEx($model, 'title', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->textField($model, 'title', array('size' => 60, 'maxlength' => 255)); ?>
                </div>
            </div>

            <div class="row control-group">
                <?php echo $form->labelEx($model, 'image', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php if (isset($img) && $img != '') { ?>
                        <img src="<?php echo HSUrl::home() . '/pictures/deal/thumbs/' . $img ?>" alt=""/>
                    <?php } ?>

                    <?php echo CHtml::activeFileField($model, 'image'); ?>
                </div>
            </div>

            <div class="row control-group">
                <?php echo $form->labelEx($model, 'price', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->textField($model, 'price', array('size' => 60, 'maxlength' => 255)); ?>
                </div>
            </div>

            <div class="row control-group">
                <?php echo $form->labelEx($model, 'old_price', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->textField($model, 'old_price', array('size' => 60, 'maxlength' => 255)); ?>
                </div>
            </div>

            <div class="row control-group">
                <?php echo $form->labelEx($model, 'shipping_price', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->textField($model, 'shipping_price', array('size' => 60, 'maxlength' => 255)); ?>
                </div>
            </div>

            <div class="row control-group">
                <?php echo $form->labelEx($model, 'expired_date', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->textField($model, 'expired_date', array('id' => 'txtExpired')); ?>
                </div>
            </div>

            <div class="row control-group">
                <?php echo $form->labelEx($model, 'source', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->textField($model, 'source', array('size' => 60, 'maxlength' => 255)); ?>
                </div>
            </div>

            <div class="row control-group">
                <?php echo $form->labelEx($model, 'category_id', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->dropDownList($model, 'category_id', CHtml::listData($categories, 'id', 'name')); ?>
                </div>
            </div>
            <div class="row control-group">
                <?php echo $form->labelEx($model, 'website', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->textField($model, 'website', array('size' => 60, 'maxlength' => 255)); ?>
                </div>
            </div>
            <div class="row control-group">
                <?php echo $form->labelEx($model, 'content', array('class' => 'control-label')); ?>
                <div class="controls">
                    <?php echo $form->textArea($model, 'content', array('id' => 'txtContent', 'style' => 'width:100%', 'rows' => 6, 'cols' => 50)); ?>
                </div>
            </div>

            <div class="row control-group buttons">
                <div class="controls">
                    <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('class' => 'btn btn-default')); ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $this->endWidget(); ?>

<script type="text/javascript">
    $(document).ready(function () {
        KE.show({
            id: 'txtContent',
            height: 200,
            items: [
                'source', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript', 'selectall', '-',
                'title', 'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold',
                'italic', 'underline', 'strikethrough', 'removeformat', 'image',
                'table', 'hr', 'emoticons', 'link', 'unlink', 'about'
            ]
        });

        $("#txtExpired").datepicker({
            yearRange: "-80:+0", // this is the option you're looking for
            showOn: "both",
            changeYear: true,
            changeMonth: true,
            dateFormat: "yy-mm-dd"
        });

    });

</script>

